package com.dankegongyu.lib.common.widget.recyclerview.layoutmanger;

import android.content.Context;
import android.util.AttributeSet;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

/**
 * 不可滚动的LinearLayoutManager
 *
 * @author wupuquan
 * @version 1.0
 * @since 2018/9/8 15:07
 */
@Deprecated
public class LinearLayoutManagerNonScrollable extends LinearLayoutManager {

    public LinearLayoutManagerNonScrollable(Context context) {
        super(context);
    }

    public LinearLayoutManagerNonScrollable(Context context, int orientation, boolean reverseLayout) {
        super(context, orientation, reverseLayout);
    }

    public LinearLayoutManagerNonScrollable(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    public boolean canScrollVertically() {
        return false;
    }

    @Override
    public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
        try {
            // 解决bug: java.lang.IndexOutOfBoundsException. Inconsistency detected. Invalid item position 6(offset:6).state:7
            super.onLayoutChildren(recycler, state);
        } catch (IndexOutOfBoundsException e) {
            e.printStackTrace();
        }
    }

}
